package com.chenlong.pc.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.chenlong.pc.dao.PersonDao;
import com.chenlong.pc.dao.LogDao;
import com.chenlong.pc.entity.Person;
import com.chenlong.pc.service.BaseService;

@Service
public class PersonService implements BaseService<Person> {

	private PersonDao personDao;
	
	private LogDao logDao;
	
	@Autowired
	public void setPersonDao(PersonDao personDao) {
		this.personDao = personDao;
	}
	
	@Autowired
	public void setLogDao(LogDao logDao) {
		this.logDao = logDao;
	}

	@Override
	public List<Person> findAll(Map<String, Object> params) {
		return personDao.findAll(params);
	}

	@Override
	public Person findById(Map<String, Object> params) {
		return personDao.findById(params);
	}

	@Override
	public List<Person> findTop(Map<String, Object> params) {
		return personDao.findTop(params);
	}

	@Override
	public int countAll(Map<String, Object> params) {
		return personDao.countAll(params);
	}

	@Override
	public void delete(Map<String, Object> params, Map<String, Object> logParam) {
		personDao.delete(params);
		logDao.save(logParam);
	}

	@Override
	public void save(Map<String, Object> params, Map<String, Object> logParam) {
		personDao.save(params);
		logDao.save(logParam);
	}

	@Override
	public void update(Map<String, Object> params,  Map<String, Object> logParam) {
		personDao.update(params);
		logDao.save(logParam);
	}
	
}
